Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonlint

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonlint

Validate JSON

  • 1.6.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
215K
increased by1.86%
Maintainers
1
Weekly downloads
 
Created

What is jsonlint?

jsonlint is a JSON parser and validator. It helps in validating JSON data, ensuring that it is correctly formatted and adheres to JSON standards. It can also pretty-print JSON data, making it easier to read and debug.

What are jsonlint's main functionalities?

Validate JSON

This feature allows you to validate a JSON string. If the JSON is valid, it will print 'Valid JSON'. If the JSON is invalid, it will catch the error and print 'Invalid JSON' along with the error details.

const jsonlint = require('jsonlint');
const jsonString = '{ "name": "John", "age": 30 }';
try {
  jsonlint.parse(jsonString);
  console.log('Valid JSON');
} catch (e) {
  console.error('Invalid JSON', e);
}

Pretty Print JSON

This feature allows you to pretty-print a JSON string. It parses the JSON and then uses JSON.stringify to format it with indentation, making it easier to read.

const jsonlint = require('jsonlint');
const jsonString = '{ "name": "John", "age": 30 }';
try {
  const parsed = jsonlint.parse(jsonString);
  const pretty = JSON.stringify(parsed, null, 2);
  console.log(pretty);
} catch (e) {
  console.error('Invalid JSON', e);
}

Other packages similar to jsonlint

Keywords

FAQs

Package last updated on 21 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc